{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport { unstable_useEventCallback as useEventCallback } from '@mui/utils';\nimport extractEventHandlers from '../utils/extractEventHandlers';\n/**\n * The basic building block for creating custom snackbar.\n *\n * Demos:\n *\n * - [Snackbar](https://mui.com/base/react-snackbar/)\n */\n\nexport default function useSnackbar(parameters) {\n  var _parameters$autoHideD = parameters.autoHideDuration,\n    autoHideDuration = _parameters$autoHideD === void 0 ? null : _parameters$autoHideD,\n    _parameters$disableWi = parameters.disableWindowBlurListener,\n    disableWindowBlurListener = _parameters$disableWi === void 0 ? false : _parameters$disableWi,\n    onClose = parameters.onClose,\n    open = parameters.open,\n    ref = parameters.ref,\n    resumeHideDuration = parameters.resumeHideDuration;\n  var timerAutoHide = React.useRef();\n  React.useEffect(function () {\n    if (!open) {\n      return undefined;\n    }\n    /**\n     * @param {KeyboardEvent} nativeEvent\n     */\n\n    function handleKeyDown(nativeEvent) {\n      if (!nativeEvent.defaultPrevented) {\n        // IE11, Edge (prior to using Blink?) use 'Esc'\n        if (nativeEvent.key === 'Escape' || nativeEvent.key === 'Esc') {\n          // not calling `preventDefault` since we don't know if people may ignore this event e.g. a permanently open snackbar\n          onClose == null ? void 0 : onClose(nativeEvent, 'escapeKeyDown');\n        }\n      }\n    }\n    document.addEventListener('keydown', handleKeyDown);\n    return function () {\n      document.removeEventListener('keydown', handleKeyDown);\n    };\n  }, [open, onClose]);\n  var handleClose = useEventCallback(function (event, reason) {\n    onClose == null ? void 0 : onClose(event, reason);\n  });\n  var setAutoHideTimer = useEventCallback(function (autoHideDurationParam) {\n    if (!onClose || autoHideDurationParam == null) {\n      return;\n    }\n    clearTimeout(timerAutoHide.current);\n    timerAutoHide.current = setTimeout(function () {\n      handleClose(null, 'timeout');\n    }, autoHideDurationParam);\n  });\n  React.useEffect(function () {\n    if (open) {\n      setAutoHideTimer(autoHideDuration);\n    }\n    return function () {\n      clearTimeout(timerAutoHide.current);\n    };\n  }, [open, autoHideDuration, setAutoHideTimer]);\n  var handleClickAway = function handleClickAway(event) {\n    onClose == null ? void 0 : onClose(event, 'clickaway');\n  }; // Pause the timer when the user is interacting with the Snackbar\n  // or when the user hide the window.\n\n  var handlePause = function handlePause() {\n    clearTimeout(timerAutoHide.current);\n  }; // Restart the timer when the user is no longer interacting with the Snackbar\n  // or when the window is shown back.\n\n  var handleResume = React.useCallback(function () {\n    if (autoHideDuration != null) {\n      setAutoHideTimer(resumeHideDuration != null ? resumeHideDuration : autoHideDuration * 0.5);\n    }\n  }, [autoHideDuration, resumeHideDuration, setAutoHideTimer]);\n  var createHandleBlur = function createHandleBlur(otherHandlers) {\n    return function (event) {\n      var onBlurCallback = otherHandlers.onBlur;\n      onBlurCallback == null ? void 0 : onBlurCallback(event);\n      handleResume();\n    };\n  };\n  var createHandleFocus = function createHandleFocus(otherHandlers) {\n    return function (event) {\n      var onFocusCallback = otherHandlers.onFocus;\n      onFocusCallback == null ? void 0 : onFocusCallback(event);\n      handlePause();\n    };\n  };\n  var createMouseEnter = function createMouseEnter(otherHandlers) {\n    return function (event) {\n      var onMouseEnterCallback = otherHandlers.onMouseEnter;\n      onMouseEnterCallback == null ? void 0 : onMouseEnterCallback(event);\n      handlePause();\n    };\n  };\n  var createMouseLeave = function createMouseLeave(otherHandlers) {\n    return function (event) {\n      var onMouseLeaveCallback = otherHandlers.onMouseLeave;\n      onMouseLeaveCallback == null ? void 0 : onMouseLeaveCallback(event);\n      handleResume();\n    };\n  };\n  React.useEffect(function () {\n    // TODO: window global should be refactored here\n    if (!disableWindowBlurListener && open) {\n      window.addEventListener('focus', handleResume);\n      window.addEventListener('blur', handlePause);\n      return function () {\n        window.removeEventListener('focus', handleResume);\n        window.removeEventListener('blur', handlePause);\n      };\n    }\n    return undefined;\n  }, [disableWindowBlurListener, handleResume, open]);\n  var getRootProps = function getRootProps() {\n    var otherHandlers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n    var propsEventHandlers = extractEventHandlers(parameters);\n    var externalEventHandlers = _extends({}, propsEventHandlers, otherHandlers);\n    return _extends({\n      ref: ref,\n      // ClickAwayListener adds an `onClick` prop which results in the alert not being announced.\n      // See https://github.com/mui/material-ui/issues/29080\n      role: 'presentation'\n    }, externalEventHandlers, {\n      onBlur: createHandleBlur(externalEventHandlers),\n      onFocus: createHandleFocus(externalEventHandlers),\n      onMouseEnter: createMouseEnter(externalEventHandlers),\n      onMouseLeave: createMouseLeave(externalEventHandlers)\n    });\n  };\n  return {\n    getRootProps: getRootProps,\n    onClickAway: handleClickAway\n  };\n}","map":{"version":3,"names":["_extends","React","unstable_useEventCallback","useEventCallback","extractEventHandlers","useSnackbar","parameters","autoHideDuration","disableWindowBlurListener","onClose","open","ref","resumeHideDuration","timerAutoHide","useRef","useEffect","undefined","handleKeyDown","nativeEvent","defaultPrevented","key","document","addEventListener","removeEventListener","handleClose","event","reason","setAutoHideTimer","autoHideDurationParam","clearTimeout","current","setTimeout","handleClickAway","handlePause","handleResume","useCallback","createHandleBlur","otherHandlers","onBlurCallback","onBlur","createHandleFocus","onFocusCallback","onFocus","createMouseEnter","onMouseEnterCallback","onMouseEnter","createMouseLeave","onMouseLeaveCallback","onMouseLeave","window","getRootProps","propsEventHandlers","externalEventHandlers","role","onClickAway"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@mui/base/SnackbarUnstyled/useSnackbar.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport { unstable_useEventCallback as useEventCallback } from '@mui/utils';\nimport extractEventHandlers from '../utils/extractEventHandlers';\n/**\n * The basic building block for creating custom snackbar.\n *\n * Demos:\n *\n * - [Snackbar](https://mui.com/base/react-snackbar/)\n */\n\nexport default function useSnackbar(parameters) {\n  const {\n    autoHideDuration = null,\n    disableWindowBlurListener = false,\n    onClose,\n    open,\n    ref,\n    resumeHideDuration\n  } = parameters;\n  const timerAutoHide = React.useRef();\n  React.useEffect(() => {\n    if (!open) {\n      return undefined;\n    }\n    /**\n     * @param {KeyboardEvent} nativeEvent\n     */\n\n\n    function handleKeyDown(nativeEvent) {\n      if (!nativeEvent.defaultPrevented) {\n        // IE11, Edge (prior to using Blink?) use 'Esc'\n        if (nativeEvent.key === 'Escape' || nativeEvent.key === 'Esc') {\n          // not calling `preventDefault` since we don't know if people may ignore this event e.g. a permanently open snackbar\n          onClose == null ? void 0 : onClose(nativeEvent, 'escapeKeyDown');\n        }\n      }\n    }\n\n    document.addEventListener('keydown', handleKeyDown);\n    return () => {\n      document.removeEventListener('keydown', handleKeyDown);\n    };\n  }, [open, onClose]);\n  const handleClose = useEventCallback((event, reason) => {\n    onClose == null ? void 0 : onClose(event, reason);\n  });\n  const setAutoHideTimer = useEventCallback(autoHideDurationParam => {\n    if (!onClose || autoHideDurationParam == null) {\n      return;\n    }\n\n    clearTimeout(timerAutoHide.current);\n    timerAutoHide.current = setTimeout(() => {\n      handleClose(null, 'timeout');\n    }, autoHideDurationParam);\n  });\n  React.useEffect(() => {\n    if (open) {\n      setAutoHideTimer(autoHideDuration);\n    }\n\n    return () => {\n      clearTimeout(timerAutoHide.current);\n    };\n  }, [open, autoHideDuration, setAutoHideTimer]);\n\n  const handleClickAway = event => {\n    onClose == null ? void 0 : onClose(event, 'clickaway');\n  }; // Pause the timer when the user is interacting with the Snackbar\n  // or when the user hide the window.\n\n\n  const handlePause = () => {\n    clearTimeout(timerAutoHide.current);\n  }; // Restart the timer when the user is no longer interacting with the Snackbar\n  // or when the window is shown back.\n\n\n  const handleResume = React.useCallback(() => {\n    if (autoHideDuration != null) {\n      setAutoHideTimer(resumeHideDuration != null ? resumeHideDuration : autoHideDuration * 0.5);\n    }\n  }, [autoHideDuration, resumeHideDuration, setAutoHideTimer]);\n\n  const createHandleBlur = otherHandlers => event => {\n    const onBlurCallback = otherHandlers.onBlur;\n    onBlurCallback == null ? void 0 : onBlurCallback(event);\n    handleResume();\n  };\n\n  const createHandleFocus = otherHandlers => event => {\n    const onFocusCallback = otherHandlers.onFocus;\n    onFocusCallback == null ? void 0 : onFocusCallback(event);\n    handlePause();\n  };\n\n  const createMouseEnter = otherHandlers => event => {\n    const onMouseEnterCallback = otherHandlers.onMouseEnter;\n    onMouseEnterCallback == null ? void 0 : onMouseEnterCallback(event);\n    handlePause();\n  };\n\n  const createMouseLeave = otherHandlers => event => {\n    const onMouseLeaveCallback = otherHandlers.onMouseLeave;\n    onMouseLeaveCallback == null ? void 0 : onMouseLeaveCallback(event);\n    handleResume();\n  };\n\n  React.useEffect(() => {\n    // TODO: window global should be refactored here\n    if (!disableWindowBlurListener && open) {\n      window.addEventListener('focus', handleResume);\n      window.addEventListener('blur', handlePause);\n      return () => {\n        window.removeEventListener('focus', handleResume);\n        window.removeEventListener('blur', handlePause);\n      };\n    }\n\n    return undefined;\n  }, [disableWindowBlurListener, handleResume, open]);\n\n  const getRootProps = (otherHandlers = {}) => {\n    const propsEventHandlers = extractEventHandlers(parameters);\n\n    const externalEventHandlers = _extends({}, propsEventHandlers, otherHandlers);\n\n    return _extends({\n      ref,\n      // ClickAwayListener adds an `onClick` prop which results in the alert not being announced.\n      // See https://github.com/mui/material-ui/issues/29080\n      role: 'presentation'\n    }, externalEventHandlers, {\n      onBlur: createHandleBlur(externalEventHandlers),\n      onFocus: createHandleFocus(externalEventHandlers),\n      onMouseEnter: createMouseEnter(externalEventHandlers),\n      onMouseLeave: createMouseLeave(externalEventHandlers)\n    });\n  };\n\n  return {\n    getRootProps,\n    onClickAway: handleClickAway\n  };\n}"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,oCAAoC;AACzD,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,yBAAyB,IAAIC,gBAAgB,QAAQ,YAAY;AAC1E,OAAOC,oBAAoB,MAAM,+BAA+B;AAChE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAe,SAASC,WAAW,CAACC,UAAU,EAAE;EAC9C,4BAOIA,UAAU,CANZC,gBAAgB;IAAhBA,gB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